package com.rs.game.npc.combat.impl;

import com.rs.game.Animation;
import com.rs.game.Entity;
import com.rs.game.Graphics;
import com.rs.game.World;
import com.rs.game.npc.NPC;
import com.rs.game.npc.combat.CombatScript;
import com.rs.game.npc.combat.NPCCombatDefinitions;
import com.rs.utils.Utils;

public class IcyBonesCombat extends CombatScript {

	@Override
	public Object[] getKeys() {
		return new Object[] { "Icy Bones" };
	}

	@Override
	public int attack(NPC npc, Entity target) {
		NPCCombatDefinitions defs = npc.getCombatDefinitions();
		int attackStyle = Utils.random(Utils.isOnRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0) ? 3 : 2);
		switch(attackStyle) {
		case 0:
			npc.setNextAnimation(new Animation(2125));
			npc.setNextGraphics(new Graphics(2596));
			target.setNextGraphics(new Graphics(502));
			if (Utils.random(15) == 0) {
				World.sendProjectile(npc, target, 2595, 50, 30, 40, 30, 0, 10);
				target.addFreezeDelay(6000);
				target.setNextGraphics(new Graphics(2597)); 
			}
			delayHit(npc, 1, target, getMagicHit(npc, getRandomMaxHit(npc, defs.getMaxHit(), NPCCombatDefinitions.MAGE, target)));
			break;
		case 1:
			World.sendProjectile(npc, target, 2595, 50, 30, 46, 30, 0, 10);
			npc.setNextAnimation(new Animation(2125));
			npc.setNextGraphics(new Graphics(2598));
			delayHit(npc, 1, target, getRangeHit(npc, getRandomMaxHit(npc, defs.getMaxHit(), NPCCombatDefinitions.RANGE, target)));
			break;
		case 2:
			npc.setNextAnimation(new Animation(2125));
			npc.setNextGraphics(new Graphics(2598));
			delayHit(npc, 0, target, getMeleeHit(npc, getRandomMaxHit(npc, defs.getMaxHit(), NPCCombatDefinitions.MELEE, target)));
			break;
		}
		return defs.getAttackDelay();
	}


}